<!DOCTYPE html>
<html lang="en">

<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Login</title>

    <!-- Custom fonts for this template-->
    <link href="vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">
    <link
        href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i"
        rel="stylesheet">

    <!-- Custom styles for this template-->
    <link href="css/sb-admin-2.min.css" rel="stylesheet">

    <!-- new -->
    <!-- <script src="http://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js">      
    </script> -->

    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <!-- <script src="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/js/bootstrap.min.js">
    </script> -->

</head>


<body class="bg-gradient-primary">

    <div class="container">

        <!-- Outer Row -->
        <div class="row justify-content-center">

            <div class="col-xl-10 col-lg-12 col-md-9">

                <div class="card o-hidden border-0 shadow-lg my-5">
                    <div class="card-body p-0">
                        <!-- Nested Row within Card Body -->
                        <div class="row"><img src="img/药品2.jpg" width="450" height="450" alt=""/>
<div class="col-lg-6">
                <div class="p-5">
                                    <div class="text-center">
                                      <h1 class="h4 text-gray-900 mb-4"><strong>医药批发商务平台</strong></h1>
                                    </div>

                                    <form class="user" id="form1"
                                    >
                                        <div class="form-group">
                                            <input type="text" class="form-control "
                                                id="username"   placeholder="Enter Username">
                                                <!-- aria-describedby="emailHelp" -->                                             
                                        </div>

                                        <div class="form-group">
                                            <input type="password" class="form-control "
                                                id="password" placeholder="Password">
                                        </div>

                                        <div class="form-group">
                                            <div class="custom-control custom-checkbox small">
                                                <input type="checkbox" class="custom-control-input" id="customCheck">
                                                <label class="custom-control-label" for="customCheck">Remember Me</label>
                                            </div>
                                        </div>
                                       <!-- <div class="btn btn-primary btn-user btn-block" id="login">
                                           <a href="index.html">
                                               Login
                                           </a>
                                       </div> -->
                                                                       
                                        <button type="button" class="btn btn-success btn-block" id="login">login</button>
		                        
                                        <hr>
                                    </form>

                                    <div class="text-center">
                                        <a class="small" href="forgot-password.html">Forgot Password?</a>
                                    </div>
                                    <div class="text-center">
                                        <a class="small" href="create_user.html">Create an Account!</a>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

            </div>

        </div>

    </div>

    <!-- Bootstrap core JavaScript-->
    <script src="vendor/jquery/jquery.min.js"></script>
    <script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>

    <!-- Core plugin JavaScript-->
    <script src="vendor/jquery-easing/jquery.easing.min.js"></script>

    <!-- Custom scripts for all pages-->
    <script src="js/sb-admin-2.min.js"></script>



    <!-- <script type="text/javascript" src="<%=basePath%>xiaozhujsp/js/jquery-1.12.4.js"></script>
    <script type="text/javascript">  
    $(function(){
        $("#login").click(function(){
           var $username=$("#username");//储存文本框的jQ对象
           var $password=$("#password");//储存密码框的jQ对象
           if($username.val()==""){//判断输入的账号是否为空
               $username.next().text("账号为空").css({"font-weight":"bold","color":"red"});
               event.preventDefault();//取消提交
           }else if($password.val()==""){
             $password.next().text("密码为空").css({"font-weight":"bold","color":"red"});
             event.preventDefault();
           }else{
             //登录的ajax
             $.ajax({
                 url:"http://rap2api.tao bao.org/app/mock/281919/login",
                 type:"get",
                 data:{
                     "username":$username.val(),
                     "password":$password.val()
                 },
                 dataType: "json",  
                 success:function(data){
                     console.log(data);
                     //data = JSON.parse(data);
                     if(data=="FALSE"){
                         $username.next().text("用户名或密码错误").css({"font-weight":"bold","color":"red"});
                         $password.next().text("用户名或密码错误").css({"font-weight":"bold","color":"red"});
                     }else{
                         alert("登录成功");
                         window.location.href = 'http://www.baidu.com'; 
                     }

                 }
            });
         }
     });
    });
</script>  -->

<script>
        $(function(){
            $('#login').on("click",function () {            
                var username = $("#username").val();
                var password = $("#password").val();
                if($("#username").val()==""){//判断输入的账号是否为空
                    alert("用户名不能为空，请重新输入！");
                    console.log("aa");
                }
                else if($("#password").val()==""){//密码空
                    alert("密码不能为空，请重新输入！");
                } 
                else{              
                console.log(username);
                $.ajax({
                    url:"http://210.30.97.103:20305/login/users",
                    type:"get",    
                    data:{
                       "username":username,
                       "password":password
                       //"rember":rember 
                    },                   
                    dataType:"json",
                    success:function(result){
                        console.log(result);
                        //data = JSON.stringify(data);
                        //data=data.responseText;
                        if(result.check==false){
                            alert("用户名或密码错误！");
                        }
                        else{
                            alert("登陆成功！");
                            $.ajax({
                                url:"http://210.30.97.103:20305/login/UserByUsername",
                                type:"get",
                                data:{
                                    "username":username,
                                },
                                dataType:"json",
                                success:function (user){
                                    if(user.oid==null||user.oid==0){
                                        window.location.href="choose_platform.html?"+$("#username").val()+"";
                                    }
                                    else if(user.is_organization_accept == 0){
                                        alert("您的申请审核未通过,请耐心等待!");
                                    }
                                    else if(user.user_authority==6||user.user_authority==5){
                                        window.location.href = "platform_manager.html?"+$("#username").val()+"";
                                    }
                                    else if(user.user_authority==2){
                                        window.location.href = "org_manager.html?"+$("#username").val()+"";
                                    }
                                    else if(user.user_authority==3){
                                        window.location.href = "buyer_manager.html?"+$("#username").val()+"";
                                    }
                                    else if(user.user_authority==9){
                                        window.location.href = "buyer_operator.html?"+$("#username").val()+"";
                                    }
                                    else if(user.user_authority==7){
                                        window.location.href = "seller_operator.html?"+$("#username").val()+"";
                                    }
                                }
                            })
                        }
                        
                    }
                 })              
                }
            });
        });
</script> 

</body>

</html>